using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using TangLiveRecorder.Controls;
using TangLiveRecorder.Services;

namespace TangLiveRecorder.Extensions
{
    public static class ServiceRegisterExtension
    {
        /// <summary>
        /// 注册服务
        /// </summary>
        public static IServiceCollection AddServices(this IServiceCollection services)
        {
            services.AddSingleton<MainWindow>();
            services.AddSingleton<LiveControl>();
            services.AddSingleton<FileControl>();
            services.AddSingleton<LogControl>();
            services.AddSingleton<AddLiveControl>();
            services.AddSingleton<SettingControl>();
            services.AddSingleton<DataPersistenceService>();
            services.AddSingleton<RecordingService>();
            services.AddSingleton<PollingService>(provider =>
            {
                var recordingService = provider.GetRequiredService<RecordingService>();
                return new PollingService(10, recordingService);
            });

            return services;
        }
    }
}